package org.devocean.groupbuying.web.frontend.displaybeans;

import java.util.Calendar;
import java.util.Date;
import org.devocean.groupbuying.domain.SerialKey;

public class SerialKeyBean {

	
	private Integer serialKeyID;
	private String serialKey;
	private String titleProduct;
	private Double price;
	private Date statusDate;
	private Date expireDate;
	private String descriptionDeal;
	private String mediaPath;
	private Date usedDate;
	private Boolean used;
	private String voucherLocation;
	private Boolean expired=false;
	
	

	public SerialKeyBean(SerialKey serialKey) {
			
			this.setVoucherLocation(serialKey.getVoucher().getVoucherLocation());
			this.serialKeyID = serialKey.getSerialKeyID();
			this.serialKey = serialKey.getSerial();
			this.price = serialKey.getItem().getAmount();
			this.statusDate =serialKey.getItem().getStatusDate();
			this.expireDate = serialKey.getVoucher().getExpireDate();
			this.descriptionDeal =serialKey.getVoucher().getDiscount().getDeal().getArticlesLocalization().getArticles().iterator().next().getShorte();
			if(Calendar.getInstance().getTime().after(this.expireDate)){
				System.out.println(this.expireDate);
				this.expired=true;
			}
			
			this.titleProduct = serialKey.getItem().getDiscount().getDeal().getProduct().getArticlesLocalization().getArticles().iterator().next().getTitle();
			this.mediaPath =  serialKey.getItem().getDiscount().getDeal().getProduct().getArticlesLocalization().getMediaLocalizations().iterator().next().getMediaFilePath();
			this.setUsedDate(serialKey.getUseDate());
			this.setUsed(serialKey.getUsed());
	}

	
	public Integer getSerialKeyID() {
		return serialKeyID;
	}

	public void setSerialKeyID(Integer serialKeyID) {
		this.serialKeyID = serialKeyID;
	}

	public String getSerialKey() {
		return serialKey;
	}

	public void setSerialKey(String serialKey) {
		this.serialKey = serialKey;
	}

	public String getTitleProduct() {
		return titleProduct;
	}

	public void setTitleProduct(String titleProduct) {
		this.titleProduct = titleProduct;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Date getStatusDate() {
		return statusDate;
	}

	public void setStatusDate(Date statusDate) {
		this.statusDate = statusDate;
	}

	

	public String getDescriptionDeal() {
		return descriptionDeal;
	}

	public void setDescriptionDeal(String descriptionDeal) {
		this.descriptionDeal = descriptionDeal;
	}
	public String getMediaPath() {
		return mediaPath;
	}
	
	public void setMediaPath(String mediaPath) {
		this.mediaPath = mediaPath;
	}

	public Date getUsedDate() {
		return usedDate;
	}

	public void setUsedDate(Date usedDate) {
		this.usedDate = usedDate;
	}

	public Boolean getUsed() {
		return used;
	}

	public void setUsed(Boolean used) {
		this.used = used;
	}
	public Date getExpireDate() {
		return expireDate;
	}

	public void setExpireDate(Date expireDate) {
		this.expireDate = expireDate;
	}
	public String getVoucherLocation() {
		return voucherLocation;
	}


	public void setVoucherLocation(String voucherLocation) {
		this.voucherLocation = voucherLocation;
	}


	public Boolean getExpired() {
		return expired;
	}


	public void setExpired(Boolean expired) {
		this.expired = expired;
	}


	@Override
	public String toString() {
		return "SerialKeyBean [serialKey=" + serialKey + ", titleProduct="
				+ titleProduct + ", price=" + price + ", statusDate="
				+ statusDate + ", expiratDate=" + expireDate
				+ ", descriptionDeal=" + descriptionDeal + "]";
	}

}
